#ifndef __UART_H
#define __UART_H
#include "stm32f0xx.h"

#define USART22_TAG	30
#define USART_TAG	50
#define LOCUS_BUFFER_MAX	8

void uart_send_data(unsigned short data);
void uart_int(uint32_t bands);
void uart_print(unsigned char str[]);
uint8_t checksum_verify(uint8_t *spt, uint8_t lenght);
void Reset_RX_Complete(void);
uint8_t return_RX_Complete(void);

typedef struct{
	uint8_t usart1_rec_dd[20];
	uint8_t usart1_rec_b[USART_TAG];
	uint8_t Rx_flag;
	uint8_t RX_lengt;
}USART_RECEIVER;

typedef struct{
	uint8_t usart1_send_dd[20];
	uint8_t usart1_send_b[20];
	uint8_t Tx_tag;
	uint8_t data_load;
	uint8_t send_lengt;
	uint8_t send_interval;
	uint8_t send_event;

}USART_SENDER;

typedef struct{
	uint8_t usart2_rec_dd[20];
	uint8_t usart2_rec_b[20];
	uint8_t Rx_flag22;
	uint8_t RX_lengt22;
}USART22_RECEIVER;

typedef struct{
	uint8_t usart2_send_dd[20];
	uint8_t usart2_semd_b[30];
	uint8_t Tx_tag22;
	uint8_t events_flag22;
	uint8_t send_lengt22;
	uint8_t send_interval22;
	uint8_t load_flag22;

}USART22_SENDER;

typedef struct{
	uint8_t app_send_buffer[20];
	//uint8_t app_read_buffer[20];
	uint8_t app_send_size;
	uint8_t app_read_size;
}APP_BUFFER;

void Usart22_Reset_RX_Complete(void);
uint8_t Usart22_return_RX_Complete(void);
uint8_t return_DMA_SendComplete(void);
void Set_Tx_Complete(void);
void Usart11_Init(uint32_t baud);
void Usart22_init(uint32_t baud);
void Usart22_Reset_Tx_Complete(void);

extern APP_BUFFER App_Buffer[LOCUS_BUFFER_MAX];


extern uint8_t app_read_buffer[16];
//extern uint8_t con_buffer[USART_TAG];
extern USART_SENDER usart_send;

extern USART_RECEIVER usart_rev;
extern USART22_SENDER usart22_send;
extern USART22_RECEIVER usart22_rev;


#endif
